import axios from "axios"
import {Toast, Toat} from 'vant'
import store from '@/store'
const _axios=axios.create({
    baseURL:process.env.VUE_APP_URL
})
_axios.interceptors.request.use(
    config=>{
        if(!config.noToken){
            config.headers.Authorization=`Bearer ${store.getters['user/getToken']}`
        }
    return config
},
error=>{
    return Promise.reject(error)
})
_axios.interceptors.response.use(
    res=>{
    return res.data
},
error=>{
    if(error.response.data&&error.response.data.message){
        Toast.fail(error.response.data.message)
    }
    return Promise.reject(error)
})
export default _axios